﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Client_Web.ServiceReference;

namespace Client_Web
{
    public partial class AlbumView : System.Web.UI.Page
    {
        protected AlbumStruct album;

        protected List<PictureStruct> pictureList;

        protected void Page_Load(object sender, EventArgs e)
        {
            album = new AlbumStruct();
            album.id = Request.QueryString["albumId"];
            pictureList = new List<PictureStruct>();

            if (null != album.id)
            {
                ServiceClient serviceClient = new ServiceClient();
                string[] data = Util.CleanAndSplit(serviceClient.getAlbumInfo(album.id));
                album.name = data[1];
                album.date = data[2];

                string[] pictureStringList = serviceClient.getAlbumPicture(album.id);

                for (int i = 1; i < pictureStringList.Length; i++)
                {
                    data = Util.CleanAndSplit(pictureStringList[i]);

                    PictureStruct picture = new PictureStruct();
                    picture.id = data[0];
                    picture.name = data[1];
                    pictureList.Add(picture);
                }

                Title = "Album #" + album.id + "&nbsp;-&nbsp;" + album.name;
            }
        }
    }
}